﻿@{
    Layout = "~/Views/Shared/_LayoutEmpty.cshtml";
}
@model UserData
<script src="~/Scripts/jaws-form.js"></script>
<script src="~/Scripts/jaws-input.js"></script>
<div class="regist">
    <div class="header">
        <a href="/">
            <div class="logo">

            </div>
        </a>
        <div class="logoright">
            已有账号？
            <a href="@Url.DomainRouteUrl(AreasConfig.Web, "index", "login")">立即登录</a>
        </div>
    </div>
    <div class="content">
        @if (Model.RegistStep == 2)
        {

            <div class="seccess-head">
                <div class="seccess-info">
                    <div class="sec"></div>
                    <div class="info">
                        <span>恭喜您注册成功</span>
                        <p>新的投资旅程现已开始，您现在可以：</p>
                    </div>
                </div>
                <div class="seccess-href">
                    <a href="#">进入个人中心</a>
                </div>
                <p class="secess-more">还可以体验</p>
            </div>
            <div class="seccess-list">
                <a href="#" class="seccess-item">
                    <div class="seccess-pro daywin">
                        <h4>天天赢 T+N</h4>
                        <p>短线神器，我出资金，您来炒股</p>
                    </div>
                </a>
                <a href="#" class="seccess-item">
                    <div class="seccess-pro stock">
                        <h4>股票配资</h4>
                        <p>炒股利器，6倍杠杆，涨停赚60%</p>
                    </div>
                </a>
                <a href="#" class="seccess-item">
                    <div class="seccess-pro free">
                        <h4>免费体验</h4>
                        <p>赠送2000实盘资金，赢了都归您</p>
                    </div>
                </a>
                <a href="#" class="seccess-item">
                    <div class="seccess-pro pk">
                        <h4>实盘大赛</h4>
                        <p>免费提供100,000,000元操盘资金</p>
                    </div>
                </a>
            </div>
        }
        else
        {
            <h3>
                免费注册
                <span>注册就送<b>100</b>元</span>
            </h3>
            <div class="step">
                @if (Model.RegistStep == 0)
                {
                    <div class="bar1"></div>
                }
                else if (Model.RegistStep == 1)
                {
                    <div class="bar2"></div>
                }
                else
                {
                    <div class="bar3"></div>
                }
            </div>
            <div class="form">
                @if (Model.RegistStep == 0)
                {
                    <div id="Step0">
                        <form mark="StockForm" action="@Url.DomainRouteUrl(AreasConfig.Web, "index", "regist")" method="POST">
                            <div class="item">
                                <input type="text" mark="ShowInput" class="ui-input" value="用户名"/>
                                @Html.TextEdit("UserName", "", "", new {Class = "ui-input", style = "display:none", mark = "HideInput"}, new {req = 1, maxlen = 30, minlen = 4,stop = 1}, new {label = "用户名", helper = "4-16位字母、数字、下划线或中文"})
                                <div class="ico-username"></div>
                            </div>
                            <div class="item">
                                <input type="text" mark="ShowInput" class="ui-input" value="密码"/>@Html.TextEditPassword("UserPassword", "", new {Class = "ui-input", style = "display:none", mark = "HideInput"}, new {req = 1, maxlen = 30, minlen = 6, reg = "^[0-9|a-z|A-Z]{6,}$"}, new {label = "密码", helper = "6-16位数字和字母组成"})
                                <div class="ico-password"></div>
                            </div>
                            <div class="item">
                                <input type="text" mark="ShowInput" class="ui-input" value="确认密码"/>@Html.TextEditPassword("UserPassword1", "", new {Class = "ui-input", style = "display:none", mark = "HideInput"}, new {req = 1, maxlen = 30, minlen = 6, com = "UserPassword"}, new {label = "确认密码", helper = "再次输入密码"})
                                <div class="ico-password"></div>
                            </div>
                            <div class="item">
                                <label>
                                    <input id="agreeBox" type="checkbox" checked="checked"> 我已阅读并同意<a href="javascript:void(0);">《赢在投资网站服务协议》</a>
                                </label>
                            </div>
                            <div class="item" style="padding-bottom: 60px;">
                                <a type="submit" id="Next0" tag="button" class="ui-btn" href="javascript:void(0)">下一步</a>
                            </div>
                        </form>
                    </div>
                }
                else
                {
                    <div id="Step1">
                        <form mark="StockForm" action="@Url.DomainRouteUrl(AreasConfig.Web, "check", "regist")" method="POST">
                            <div class="item">
                                <input type="text" mark="ShowInput" class="ui-input" value="手机号"/>@Html.TextEdit("UserPhone", "", "", new { Class = "ui-input", style = "display:none", mark = "HideInput" }, new { req = 1, phone = 1, stop = 1 }, new { label = "手机号", helper = "请输入手机号" })
                                <div class="ico-phone"></div>
                            </div>
                            <div class="item">
                                <input type="text" mark="ShowInput" class="ui-input phonecheck" value="短信验证码" style="width: 120px"/>@Html.TextEdit("CheckCode", "", "", new {Class = "ui-input phonecheck", style = "display:none;width:120px;", mark = "HideInput"}, new {req = 1, num = 1, stop = 1}, new {label = "短信验证码", helper = "请输入短信验证码"})
                                <div class="ico-lock"></div>
                                <a href="javascript:void(0)" id="GetLockCode" class="btn-getlock">获取短信验证码</a>
                            </div>
                            <input type="hidden" value="@Model.UserName" name="UserName" id="UserName"/>
                            <input type="hidden" value="@Model.UserPassword" name="UserPassword" id="UserPassword"/>
                            <div class="item" style="padding-bottom: 60px;">
                                <a type="button" id="Next1" tag="button" class="ui-btn" href="javascript:void(0)">验证</a>
                            </div>
                        </form>
                    </div>
                }
            </div>
        }
    </div>
    <div class="footer">
        <div class="sbox">
            © 2013-2014 赢在投资 All rights reserved 臣乾金融信息服务（上海）有限公司 <a class="grey1" target="_blank" href="http://www.miibeian.gov.cn/">沪ICP备14012497号</a>
        </div>
    </div>
</div>

@*<div class="stock-window checkcode" id="Checkcode-Window" style="width: 400px">
    <dl>
        <dt>用户登录<span></span></dt>
        <dd>
            <label>
                输入图片数字&nbsp;&nbsp;<input type="text" id="Checkcode" /><img id="Code" src="@Url.DomainRouteUrl(AreasConfig.Web, "ValidateCode", "Regist")" style="float: right" onclick="this.src = '@Url.DomainRouteUrl(AreasConfig.Web, "ValidateCode", "Regist")?' + new Date().getTime()" ; />
            </label>
            <label>
                <input type="button" class="button check" value="登 录" />
            </label>
        </dd>
    </dl>
</div>*@
<script type="text/javascript">
    $(function() {
        $("input[mark=ShowInput]").bind({
            "focusin.page": function() {
                $(this).hide().next().show().focus();
            }
        });
        $("input[mark=HideInput]").bind({
            "focusout.page": function() {
                var $this = $(this);
                if ($.trim($this.val()) == "") {
                    $this.hide().prev().show();
                }
            }
        });

        $("#UserName").bind("focusout.check", function () {
            var $this = $(this);
            var user = $this.val();
            if ($this.data("result").result) {
                $.jajax({
                    url: "@Url.DomainRouteUrl(AreasConfig.Web, "CheckUserName", "regist")",
                    params: { userName: user },
                    callback: function(ret) {
                        if (ret && ret.data) {
                            $this.data("result").result = false;
                            $this.input().message.error("UserName", "已存在");
                        } else {
                            $this.input().message.right("UserName");
                        }
                    }
                });
            }
        });

        $("#UserPhone").bind("focusout.check", function () {
            var $this = $(this);
            var phone = $this.val();
            if ($this.data("result").result) {
                $.jajax({
                    url: "@Url.DomainRouteUrl(AreasConfig.Web, "CheckUserPhone", "regist")",
                    params: { userHone: phone },
                callback: function(ret) {
                    if (ret && ret.data) {
                        $this.data("result").result = false;
                        $this.input().message.error("UserPhone", "已存在");
                    } else {
                        $this.input().message.right("UserPhone");
                    }
                }
            });
        }
        });

       
        window.ButtonClick = function () {
            var regist = {};
            var $UserName = $("#UserName");
            var $Password = $("#UserPassword");
            var $UserPhone = $("#UserPhone");
            var $CheckCode = $("#CheckCode");
            regist.UserName = $.trim($UserName.val());
            regist.UserPassword = $.trim($Password.val());
            regist.UserPhone = $.trim($UserPhone.val());
            regist.CheckCode = $.trim($CheckCode.val());
            $.jajax({
                url: "@Url.DomainRouteUrl(AreasConfig.Web, "check", "regist")",
                params: regist,
                callback: function(ret) {
                    if (!ret || !ret.data) {
                        $CheckCode.data("result").result = false;
                        $CheckCode.input().message.error("CheckCode", "错误");
                    } else {
                        window.location.href = "@Url.DomainRouteUrl(AreasConfig.Web, "seccess", "regist")";
                    }
                }
            });
        };

        //获取短信验证码
        $("#GetLockCode").bind("click", function () {
            var $this = $(this);
            var $Phone = $("#UserPhone");
            var phone = $.trim($Phone.val());
            if ($Phone.data("result") == undefined) {
                $Phone.input().doVerification();
            }
            if ($Phone.data("result").result) {
                var $CheckcodeWindow = $.StockWindow({
                    title: "图片验证",
                    id: "Checkcode-Window",
                    classes: "checkcode",
                    content: '<label>输入图片数字&nbsp;&nbsp;<input type="text" id="Checkcode" /><img id="Code" src="@Url.DomainRouteUrl(AreasConfig.Web, "ValidateCode", "Regist")" style="float: right" onclick="this.src =\'@Url.DomainRouteUrl(AreasConfig.Web, "ValidateCode", "Regist")?\' + new Date().getTime()" ; /></label><label><input type="button" class="button check" value="确  定" /></label>',
                    width: 400
                });

                var $Checkcode = $("#Checkcode-Window");
                $Checkcode.find("input.button").bind("click", function() {
                    var code = $Checkcode.find("#Checkcode").val();
                    if (!code) {
                        $.jalert("请输入图片中的数字");
                        return;
                    }
                    $.jajax({
                        url: "@Url.DomainRouteUrl(AreasConfig.Web, "CheckValidateCode", "Regist")",
                        params: { code: code },
                        callback: function(ret) {
                            if (ret && ret.data) {
                                //#region 发送手机短信验证码
                                $.jajax({
                                    url: "@Url.DomainRouteUrl(AreasConfig.Web, "SendCode", "Regist")",
                                    params: { phone: phone },
                                    callback: function(ret) {
                                        if (ret) {
                                            $CheckcodeWindow.CloseWindow();
                                        }
                                    }
                                });
                                $this.addClass("disable");

                                var i = 60;
                                var timer=function() {
                                    var n = i--;
                                    $this.html(n + "秒后重新获取");
                                    if (n == 0) {
                                        $this.removeClass("disable").html("获取短信验证码");
                                        return;
                                    }
                                    setTimeout(timer, 1000);
                                }
                                timer();
                                //#endregion
                            } else {
                                $.jalert("验证码错误");
                            }
                        }
                    });
                });
            }
        });

    });
</script>